/*
 * Copyright (C) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import usbManager from '@ohos.usbManager'
import deviceManager from '@ohos.driver.deviceManager'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium';

export default function NoPermissionCanIUseTest() {
    describe("NoPermissionCanIUseTest", function () {
        const TAG = "[NoPermissionCanIUseTest]";
        const PERMISSION_DENIED_CODE = 201;
        const PERMISSION_DENIED_NOSYSTEM_CODE = 202;
        const TEST_DEVICE_ID = 0;
        const TEST_DRIVER_UID = 'testDriverUid'
        const TEST_FUNCTION = (data) => {
            expect(data === null).assertTrue();
            console.info("Test function is called");
        };

        let deviceNum = 0;
        const isDeviceConnected = done => {
            if (deviceNum > 0) {
                console.info("Test USB device is connected");
                return true;
            }
            console.info("Test USB device is not connected");
            expect(true).assertTrue();
            if (typeof (done) === 'function') {
                done();
            }
            return false;
        }

        beforeAll(function () {
            console.info('beforeAll called');
            try {
                const devicesList = usbManager.getDevices();
                if (Array.isArray(devicesList)) {
                    deviceNum = devicesList.length;
                }
            } catch (err) {
                console.error(TAG, `getDevices failed, message is ${err.message}`);
            }
        })

        afterAll(function () {
            console.info('afterAll called');
        })

        beforeEach(function () {
            console.info('beforeEach called');
        })

        afterEach(function () {
            console.info('afterEach called');
        })


    /**
     * @generated.time 2025-11-09 20:49:58
     * @tc.name   testDeviceManagerNoPerCanIUsek001
     * @tc.number SUB_Driver_Ext_DeviceManagerNoPerCanIUse_0100
     * @tc.desc   verify DeviceManagerCanIUse any device
     * @tc.type   FUNCTION
     * @tc.size   MEDIUMTEST
     * @tc.level  LEVEL3
     */
    it('testDeviceManagerNoPerCanIUsek001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function () {
        console.info(TAG, '----------------------testDeviceManagerNoPerCanIUsek001---------------------------');
        let flag = canIUse("SystemCapability.Driver.ExternalDevice");
        expect(flag).assertEqual(false);
    })
})
}
